package org.myOrg.spetrum.SpecificAlogrithm;

import java.util.Iterator;
import java.util.List;

import org.myOrg.spetrum.combination.Tuple;
import org.myOrg.spetrum.spectrumStruct.SpectrumFactory;
import org.myOrg.spetrum.spectrumStruct.SpetrumAnalyseBase;
import org.myOrg.spetrum.testObject.TestSuite;
import org.myOrg.spetrum.testRun.TestRun;

public class SpectrumAnalyseDeepFirst extends SpetrumAnalyseBase{

	private double deepValue;

	public SpectrumAnalyseDeepFirst(TestRun run,int[] param, TestSuite wrongTestCases,
			TestSuite rightTestCases) {
		super(run ,param, wrongTestCases , rightTestCases);
		this.id = SpectrumFactory.DEEPFIRST;
	}
	
	public SpectrumAnalyseDeepFirst(){
		super();
		this.id  =SpectrumFactory.DEEPFIRST;
	}
	
	@Override
	public void init() {
		List<Tuple> tuples = setUp.getCandidateHeadTuple();
		Iterator<Tuple> itrTuple = tuples.iterator();
	
		deepValue = getTupleManager().size() + 1;
		
		while (itrTuple.hasNext()) {
			deepSerchSetSuspicion(itrTuple.next());
		}
	}
	
	public void deepSerchSetSuspicion(Tuple tuple) {
		
		if(getTupleManager().getTupleAnalyseStructByTuple(tuple).getSuspicion() != 0)
			return;
		Iterator<Tuple> childs = tuple.getChildTuples().iterator();
		while (childs.hasNext()) {
			this.deepSerchSetSuspicion(childs.next());
		}
		getTupleManager().getTupleAnalyseStructByTuple(tuple).setSuspicion(deepValue);
		deepValue--;
	}

	
}
